#include <linux/sched.h>
#include <linux/sched/task.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/pid.h>
#include <linux/stdlib.h>

static inline struct task_struct *alloc_task_struct_node(int node)
{
    return kzalloc(sizeof(struct task_struct), GFP_KERNEL);
}

static int alloc_thread_stack_node(struct task_struct *tsk, int node)
{
    tsk->stack = kzalloc(THREAD_SIZE, GFP_KERNEL);
    if (!tsk->stack)
        return -ENOMEM;

    return 0;
}

static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
{
    static struct task_struct *tsk;

    tsk = alloc_task_struct_node(node);

    alloc_thread_stack_node(tsk, node);

    return tsk;
}

struct task_struct *copy_process(struct pid *pid,
                                 int trace,
                                 int node,
                                 struct kernel_clone_args *args)
{
    struct task_struct *p;
    struct task_struct *cur = current;

    p = dup_task_struct(cur, node);

    return p;
}
